package io.yizoo.business.controller;

import io.yizoo.business.entity.biz_bms_receipt;
import io.yizoo.business.entity.biz_hrm_ei_basic;
import io.elm.core.CoreController;
import io.yizoo.business.entity.biz_pmis_pj;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.EnumSet;
import java.util.List;

@RestController
@RequestMapping("/business/bms/receipt")
public class bms_receiptController extends CoreController {

    @Override
    protected void Init() {
        PowerEntity = biz_bms_receipt.class;
        PowerUse = EnumSet.of(Power.IDDelete, Power.IDAny, Power.IDGetSingle,Power.IDUpsert);
    }

    @PostMapping("/GetData")
    public Object GetData(@RequestBody String jsonStr) {
        List<?> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .From(biz_bms_receipt.class, "a")
                        .Select("a.*, b.name as sk_person_name, c.name as pj_mc")
                        .LeftJoin(biz_hrm_ei_basic.class,"b", "b.emp_code = a.sk_person")
                        .LeftJoin(biz_pmis_pj.class,"c","c.sys_code_key = a.pj_id")
                        .IsWhere("and a.remark like concat('%', #{remark}, '%')", "remark")
                        .IsPage()
                        .GetFactor());
        return JsonResultPage(ret);
    }
}
